import json

# 读取 JSON 文件
with open('C:\\Users\\86130\\Downloads\\spider\\spider\\tables.json', 'r') as file:
    data = json.load(file)

sim_list =[]
def table_name(data):
    for i in range(len(data)):
        # 提取每个 "name"
        column_names = data[i].get('column_names', [])
        # 使用字典来组织相同数字的 "name"
        name_dict = {}
        for column in column_names:
            number, name = column
            if number not in name_dict:
                name_dict[number] = []
            name_dict[number].append(name)
        similarity = 0
        db = len(name_dict) - 1
        for m in range(db):
            for n in range(m + 1, db):
                des1 = name_dict[m]
                des2 = name_dict[n]
                len1 = len(des1)
                len2 = len(des2)
                intersection = len(set(des1) & set(des2))
                sim = intersection / (len1 + len2 -intersection)
                similarity = similarity + sim
        similarity = similarity / (db * (db - 1) / 2)
        sim_list.append(similarity)
table_name(data)
sim_list = [100 * round(element, 2) for element in sim_list]
# print(sim_list)
# average = sum(sim_list) / len(sim_list)
# print(average)
count = 0
for i in sim_list:
    if(i >= 9):
        count = count + 1
print(count)